package com.bifrost.entity;

import java.io.Serializable;
import javax.persistence.*;
import java.util.List;


/**
 * The persistent class for the MEDIA database table.
 */
@Entity
@Table(name = "MEDIA",indexes = {
      @Index(name = "MEDIA_HASH_INDEX",columnList = "HASH",unique = true)
})
@NamedQuery(name = "Media.findAll", query = "SELECT m FROM Media m")
public class Media implements Serializable {


    private static final long serialVersionUID = 6255658867707765755L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "MEDIA_ID", unique = true, nullable = false)
    private Long mediaId;

    @Column(name = "HASH", length = 32)

    private String hash;
    @Column(name = "ALT_TEXT", length = 255)
    private String altText;

    /**
     * 素材类型：category 目录、coupon卡劵、avatar头像、logo 、review评论、shop 4s店、product商品、index首页
     */
    @Column(name = "MEDIA_TAGS", length = 255)
    private String mediaTags;

    @Column(length = 100, name = "TITLE")
    private String title;

    @Column(nullable = false, length = 255, name = "URL")
    private String url;

    @Column(  name = "PATH")
    private String path;

    @Column(name = "WIDTH")
    private Integer width;

    @Column(name = "HEIGHT")
    private Integer height;

    @Column(name = "SIZE")
    private Long size;

    //bi-directional many-to-one association to Category

    @OneToMany(mappedBy = "media")
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<Category> categories;

    //bi-directional many-to-one association to Coupon

    @OneToMany(mappedBy = "media")
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<Coupon> coupons;

    //bi-directional many-to-one association to Customer

    @OneToMany(mappedBy = "media")
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<Customer> customers;

    //bi-directional many-to-one association to MerchantStore

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "MERCHANT_ID" ,foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
    private MerchantStore merchantStore;

    //bi-directional many-to-one association to MerchantStore

    @OneToMany(mappedBy = "media")
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<MerchantStore> merchantStores;

    //bi-directional many-to-one association to ReviewMediaMap

    @OneToMany(mappedBy = "media")
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<ReviewMediaMap> reviewMediaMaps;

    //bi-directional many-to-one association to SkuMediaMap

    @OneToMany(mappedBy = "media")
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<SkuMediaMap> skuMediaMaps;

    @OneToMany(mappedBy = "media")
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<ReturnMediaMap> returnMediaMaps;

    @OneToMany(mappedBy = "indexRegionImg", fetch = FetchType.LAZY)
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<IndexSettingRegion> indexSettingRegion;


    @OneToMany(mappedBy = "indexSettingImg", fetch = FetchType.LAZY)
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<IndexSetting> indexSetting;

    @OneToOne(mappedBy = "brandLogo", fetch = FetchType.LAZY)
    @org.hibernate.annotations.ForeignKey(name = "none")
    private ProductBrand productBrand;

    public Media() {
    }

    public Long getMediaId() {
        return this.mediaId;
    }

    public void setMediaId(Long mediaId) {
        this.mediaId = mediaId;
    }

    public String getHash() {
        return hash;
    }

    public void setHash(String hash) {
        this.hash = hash;
    }

    public String getAltText() {
        return this.altText;
    }

    public void setAltText(String altText) {
        this.altText = altText;
    }

    public String getMediaTags() {
        return this.mediaTags;
    }

    public void setMediaTags(String mediaTags) {
        this.mediaTags = mediaTags;
    }

    public String getTitle() {
        return this.title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getUrl() {
        return this.url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public Integer getWidth() {
        return width;
    }

    public void setWidth(Integer width) {
        this.width = width;
    }

    public Integer getHeight() {
        return height;
    }

    public void setHeight(Integer height) {
        this.height = height;
    }

    public Long getSize() {
        return size;
    }

    public void setSize(Long size) {
        this.size = size;
    }

    public List<Category> getCategories() {
        return this.categories;
    }

    public void setCategories(List<Category> categories) {
        this.categories = categories;
    }

    public Category addCategory(Category category) {
        getCategories().add(category);
        category.setMedia(this);

        return category;
    }

    public Category removeCategory(Category category) {
        getCategories().remove(category);
        category.setMedia(null);

        return category;
    }

    public List<Coupon> getCoupons() {
        return this.coupons;
    }

    public void setCoupons(List<Coupon> coupons) {
        this.coupons = coupons;
    }

    public Coupon addCoupon(Coupon coupon) {
        getCoupons().add(coupon);
        coupon.setMedia(this);

        return coupon;
    }

    public Coupon removeCoupon(Coupon coupon) {
        getCoupons().remove(coupon);
        coupon.setMedia(null);

        return coupon;
    }

    public List<Customer> getCustomers() {
        return this.customers;
    }

    public void setCustomers(List<Customer> customers) {
        this.customers = customers;
    }

    public Customer addCustomer(Customer customer) {
        getCustomers().add(customer);
        customer.setMedia(this);

        return customer;
    }

    public Customer removeCustomer(Customer customer) {
        getCustomers().remove(customer);
        customer.setMedia(null);

        return customer;
    }

    public MerchantStore getMerchantStore() {
        return this.merchantStore;
    }

    public void setMerchantStore(MerchantStore merchantStore) {
        this.merchantStore = merchantStore;
    }

    public List<MerchantStore> getMerchantStores() {
        return this.merchantStores;
    }

    public void setMerchantStores(List<MerchantStore> merchantStores) {
        this.merchantStores = merchantStores;
    }

    public MerchantStore addMerchantStore(MerchantStore merchantStore) {
        getMerchantStores().add(merchantStore);
        merchantStore.setMedia(this);

        return merchantStore;
    }

    public MerchantStore removeMerchantStore(MerchantStore merchantStore) {
        getMerchantStores().remove(merchantStore);
        merchantStore.setMedia(null);

        return merchantStore;
    }

    public List<ReviewMediaMap> getReviewMediaMaps() {
        return this.reviewMediaMaps;
    }

    public void setReviewMediaMaps(List<ReviewMediaMap> reviewMediaMaps) {
        this.reviewMediaMaps = reviewMediaMaps;
    }

    public ReviewMediaMap addReviewMediaMap(ReviewMediaMap reviewMediaMap) {
        getReviewMediaMaps().add(reviewMediaMap);
        reviewMediaMap.setMedia(this);

        return reviewMediaMap;
    }

    public ReviewMediaMap removeReviewMediaMap(ReviewMediaMap reviewMediaMap) {
        getReviewMediaMaps().remove(reviewMediaMap);
        reviewMediaMap.setMedia(null);

        return reviewMediaMap;
    }

    public List<SkuMediaMap> getSkuMediaMaps() {
        return this.skuMediaMaps;
    }

    public void setSkuMediaMaps(List<SkuMediaMap> skuMediaMaps) {
        this.skuMediaMaps = skuMediaMaps;
    }

    public SkuMediaMap addSkuMediaMap(SkuMediaMap skuMediaMap) {
        getSkuMediaMaps().add(skuMediaMap);
        skuMediaMap.setMedia(this);

        return skuMediaMap;
    }

    public SkuMediaMap removeSkuMediaMap(SkuMediaMap skuMediaMap) {
        getSkuMediaMaps().remove(skuMediaMap);
        skuMediaMap.setMedia(null);

        return skuMediaMap;
    }

    public List<IndexSettingRegion> getIndexSettingRegion() {
        return indexSettingRegion;
    }

    public void setIndexSettingRegion(List<IndexSettingRegion> indexSettingRegion) {
        this.indexSettingRegion = indexSettingRegion;
    }

    public List<IndexSetting> getIndexSetting() {
        return indexSetting;
    }

    public void setIndexSetting(List<IndexSetting> indexSetting) {
        this.indexSetting = indexSetting;
    }

    public ProductBrand getProductBrand() {
        return productBrand;
    }

    public void setProductBrand(ProductBrand productBrand) {
        this.productBrand = productBrand;
    }

    public List<ReturnMediaMap> getReturnMediaMaps() {
        return returnMediaMaps;
    }

    public void setReturnMediaMaps(List<ReturnMediaMap> returnMediaMaps) {
        this.returnMediaMaps = returnMediaMaps;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }
}